Release 10.1A: OpenEdge Development:
Progress 4GL Reference


LOGICAL function

Converts any data type into the LOGICAL data type.

Syntax

LOGICAL (<expression> [, <char-expression-format>]  ) 

expression

An expression in the data type that you want to convert to logical.

char-expression-format

A character expression that evaluates to a valid logical format, such as "si/no", or "da/nyet". This argument is ignored unless <expression> is of CHARACTER type. Also, this argument is only needed if <expression> evaluates to something other than the usual TRUE or FALSE, or YES or NO values.

Example

The following code fragment illustrates the Logical function:

DEFINE VARIABLE mychar AS CHAR. 
DEFINE VARIABLE v-log AS LOGICAL. 
	mychar="si". 
v-log=LOGICAL (mychar, "si/no") 
/*v-log is TRUE*/ 

If the value of <expression> is the Unknown value (?), the LOGICAL function returns the Unknown value (?).

If <expression> is of type DECIMAL, INTEGER, DATE, or HANDLE, the function returns TRUE if the value of <expression> is nonzero. If the value of <expression> is 0, it returns FALSE. The second argument is ignored if present.

If <expression> is of type CHARACTER, it returns TRUE or FALSE depending on the value in the expression and the format used. Whether or not <char-expression-format> is given, the case-insensitive values TRUE, FALSE, YES, NO, abbreviated to 1 character, are always accepted. For example, a "Y" is interpreted as TRUE.

If <char-expression-format> is given, it is validated. If it is not valid, an error message appears and the Unknown value (?) is returned. Otherwise, the format is used to interpret the character string if it is not one of the following: TRUE, FALSE, YES, or NO. For example, LOGICAL ("si", "si/no" ) returns TRUE.

Data types such as RAW, MEMPTR, LVARBINARY, and so on return the Unknown value (?), but this is not considered an error.

See also

STRING function, INTEGER function, DATE function


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095